package com.eeds.controller.pc;

import com.eeds.base.BaseController;
import com.eeds.common.model.BaseWrapper;
import com.eeds.interceptor.NeedAuth;
import com.eeds.model.culture.req.ReqUpdateCultureVO;
import com.eeds.model.file.req.ReqAddFileInfoVO;
import com.eeds.model.file.req.ReqDeleteFileInfoVO;
import com.eeds.model.file.req.ReqGetFileInfoVO;
import com.eeds.model.file.req.ReqUpdateFileInfoVO;
import com.eeds.model.file.res.ResGetFileVO;
import com.eeds.service.file.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@RestController
@Api(value = "文件柜接口", description = "文件柜接口")
@RequestMapping("pc/fileCabinet/")
public class FileCabinetController extends BaseController {


    @Autowired
    private FileService fileService;



    /**
     * description:获取文件列表
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth
    @RequestMapping(value = "/getFileList", method = RequestMethod.GET)
    @ApiOperation("获取文件列表")
    public BaseWrapper<List<ResGetFileVO>> getFileList(){
        List<ResGetFileVO> result = fileService.getFileList();
        return new BaseWrapper<>(result);
    }

    /**
     * description:获取文件信息
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth
    @RequestMapping(value = "/getFileInfo", method = RequestMethod.GET)
    @ApiOperation("获取文件信息")
    public BaseWrapper<ResGetFileVO> getFileInfo(@Valid @ModelAttribute ReqGetFileInfoVO reqGetFileInfoVO){
        ResGetFileVO result = fileService.getFileInfo(reqGetFileInfoVO);
        return new BaseWrapper<>(result);
    }

    /**
     * description:添加文件信息
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth(role = 1)
    @RequestMapping(value = "/addFileInfo", method = RequestMethod.POST)
    @ApiOperation("添加文件信息")
    public BaseWrapper<Integer> addFileInfo(@Valid @ModelAttribute ReqAddFileInfoVO reqAddFileInfoVO){
        Integer result = fileService.addFileInfo(reqAddFileInfoVO);
        return new BaseWrapper<>(result);
    }

    /**
     * description:修改文件信息
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth(role = 1)
    @RequestMapping(value = "/updateFileInfo", method = RequestMethod.POST)
    @ApiOperation("修改文件信息")
    public BaseWrapper<Integer> updateFileInfo(@Valid @ModelAttribute ReqUpdateFileInfoVO reqUpdateFileInfoVO){
        Integer result = fileService.updateFileInfo(reqUpdateFileInfoVO);
        return new BaseWrapper<>(result);
    }

    /**
     * description:删除文件信息
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth(role = 1)
    @RequestMapping(value = "/deleteFileInfo", method = RequestMethod.POST)
    @ApiOperation("删除文件信息")
    public BaseWrapper<Integer> deleteFileInfo(@Valid @ModelAttribute ReqDeleteFileInfoVO reqDeleteFileInfoVO){
        Integer result = fileService.deleteFileInfo(reqDeleteFileInfoVO);
        return new BaseWrapper<>(result);
    }

}
